home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 104 / MacAddict_104_2005-04.iso / Software / Internet & Communication / WordPress 1.2.2 freeware.dmg / wordpress / wp-admin / options-permalink.php < prev    next >
Encoding:
PHP Script  |  2004-05-14  |  5.3 KB  |  147 lines

  1. <?php
  2. require_once('../wp-includes/wp-l10n.php');
  3.  
  4. $title = __('Permalink Options');
  5. $parent_file = 'options-general.php';
  6.  
  7. $wpvarstoreset = array('action','standalone', 'option_group_id');
  8. for ($i=0; $i<count($wpvarstoreset); $i += 1) {
  9.     $wpvar = $wpvarstoreset[$i];
  10.     if (!isset($$wpvar)) {
  11.         if (empty($_POST["$wpvar"])) {
  12.             if (empty($_GET["$wpvar"])) {
  13.                 $$wpvar = '';
  14.             } else {
  15.                 $$wpvar = $_GET["$wpvar"];
  16.             }
  17.         } else {
  18.             $$wpvar = $_POST["$wpvar"];
  19.         }
  20.     }
  21. }
  22.  
  23. require_once('./optionhandler.php');
  24.  
  25. if (isset($_POST['submit'])) {
  26.     update_option('permalink_structure', $_POST['permalink_structure']);
  27.     $permalink_structure = $_POST['permalink_structure'];
  28.  
  29.     update_option('category_base', $_POST['category_base']);
  30.     $category_base = $_POST['category_base'];
  31. } else {
  32.     $permalink_structure = get_settings('permalink_structure');
  33.     $category_base = get_settings('category_base');
  34. }
  35.  
  36.  
  37.  
  38.     require_once('admin-header.php');
  39.     if ($user_level <= 6) {
  40.         die(__("You have do not have sufficient permissions to edit the options for this blog."));
  41.     }
  42.     require('./options-head.php');
  43. ?>
  44. <?php if (isset($_POST['submit'])) : ?>
  45. <div class="updated"><p><?php _e('Permalink structure updated.'); ?></p></div>
  46. <?php endif; ?>
  47. <div class="wrap"> 
  48.   <h2><?php _e('Edit Permalink Structure') ?></h2> 
  49.   <?php _e('<p>WordPress offers you the ability to create a custom URI structure for your permalinks and archives. The following “tags” are available:</p>')?> 
  50.  
  51. <dl>
  52.     <dt><code>%year%</code></dt>
  53.     <dd>
  54.         <?php _e('The year of the post, 4 digits, for example <code>2004</code>') ?>
  55.     </dd>
  56.     <dt><code>%monthnum%</code></dt>
  57.     <dd>
  58.         <?php _e('Month of the year, for example <code>05</code>') ?>
  59.     </dd>
  60.     <dt><code>%day%</code></dt>
  61.     <dd>
  62.         <?php _e('Day of the month, for example <code>28</code>') ?>
  63.     </dd>
  64.     <dt><code>%hour%</code></dt>
  65.     <dd>
  66.         <?php _e('Hour of the day, for example <code>15</code>') ?>
  67.     </dd>
  68.     <dt><code>%minute%</code></dt>
  69.     <dd>
  70.         <?php _e('Minute of the hour, for example <code>43</code>') ?>
  71.     </dd>
  72.     <dt><code>%second%</code></dt>
  73.     <dd>
  74.         <?php _e('Second of the minute, for example <code>33</code>') ?>
  75.     </dd>
  76.     <dt><code>%postname%</code></dt>
  77.     <dd>
  78.         <?php _e('A sanitized version of the title of the post. So “This Is A Great Post!” becomes “<code>this-is-a-great-post</code>” in the URI') ?>
  79.     </dd>
  80.     <dt><code>%post_id%</code></dt>
  81.     <dd>
  82.         <?php _e('The unique ID # of the post, for example <code>423</code>') ?>
  83.     </dd>
  84. </dl>
  85.  
  86.   <?php _e('<p>So for example a value like:</p>
  87.   <p><code>/archives/%year%/%monthnum%/%day%/%postname%/</code> </p>
  88.   <p>would give you a permalink like:</p>
  89.   <p><code>/archives/2003/05/23/my-cheese-sandwich/</code></p>
  90.   <p> In general for this you must use mod_rewrite, however if you put a filename at the beginning WordPress will attempt to use that to pass the arguments, for example:</p>
  91.   <p><code>/index.php/archives/%year%/%monthnum%/%day%/%postname%/</code> </p>
  92.   <p>If you use this option you can ignore the mod_rewrite rules. </p>') ?>
  93.   <form name="form" action="options-permalink.php" method="post"> 
  94.     <p><?php _e('Use the template tags above to create a virtual site structure:') ?></p>
  95.     <p> 
  96.       <input name="permalink_structure" type="text" style="width: 98%;" value="<?php echo $permalink_structure; ?>" /> 
  97.     </p> 
  98.     <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/taxonomy/categorias</code> would make your category links like <code>http://example.org/taxonomy/categorias/general/</code>. If you leave this blank the default will be used.') ?></p>
  99.     <p> 
  100.   <input name="category_base" type="text" style="width: 98%;" value="<?php echo $category_base; ?>" /> 
  101.      </p> 
  102.     <p class="submit"> 
  103.       <input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>"> 
  104.     </p> 
  105.   </form> 
  106. <?php
  107.  if ($permalink_structure) {
  108. ?>
  109.   <p><?php printf(__('Using the permalink structure value you currently have, <code>%s</code>, these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.'), $permalink_structure) ?></p>
  110.   <?php
  111. $site_root = str_replace('http://', '', trim(get_settings('siteurl')));
  112. $site_root = preg_replace('|([^/]*)(.*)|i', '$2', $site_root);
  113. if ('/' != substr($site_root, -1)) $site_root = $site_root . '/';
  114.  
  115. $home_root = str_replace('http://', '', trim(get_settings('home')));
  116. $home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root);
  117. if ('/' != substr($home_root, -1)) $home_root = $home_root . '/';
  118.  
  119. ?> 
  120. <form action="">
  121.     <p>
  122.         <textarea rows="5" style="width: 98%;">RewriteEngine On
  123. RewriteBase <?php echo $home_root; ?> 
  124. <?php
  125. $rewrite = rewrite_rules('', $permalink_structure);
  126. foreach ($rewrite as $match => $query) {
  127.     if (strstr($query, 'index.php')) echo 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA]\n";
  128.     else echo 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA]\n";
  129. }
  130. ?>
  131.     </textarea>
  132.     </p>
  133.     <?php printf(__('<p>If your <code>.htaccess</code> file is writable by WordPress, you can <a href="%s">edit it through your template interface</a>.</p>'), 'templates.php?file=.htaccess') ?>
  134. </form>
  135. </div> 
  136. <?php
  137. } else {
  138. ?>
  139. <p>
  140. <?php _e('You are not currently using customized permalinks. No special mod_rewrite rules are needed.') ?>
  141. </p>
  142. <?php } ?>
  143. </div>
  144.  
  145. <?php
  146. require('./admin-footer.php');
  147. ?>